﻿//----------------------------------------------------

#region 命名空间

//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using WinnerCMS.Common;
using WinnerCMS.Data;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 业务逻辑类 WinnerCMS_Bank 的摘要说明。
    /// </summary>
    public class BankManage
    {
        #region - 变量 -

        private static readonly BankDal Dal = new BankDal();

        #endregion

        #region - 构造函数 -

        #endregion

        #region - 方法 -

        /// <summary>
        /// 审核或者取消审核
        /// </summary>
        /// <param name="ID"></param>
        public void PassOrNo(string ID)
        {
            var state = Dal.PassOrNo(int.Parse(ID));

            if (state)
            {
                Log logModel = new Log();
                logModel.Type = "账户管理";
                logModel.Event = "通过审核ID" + ID;
                LogManage.Add(logModel);
            }
            else
            {
                Log logModel = new Log();
                logModel.Type = "账户管理";
                logModel.Event = "撤消审核ID" + ID;
                LogManage.Add(logModel);
            }
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <returns></returns>
        public IList<Bank> GetList()
        {
            return Dal.BindList();
        }

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        public Result Add(Bank model)
        {
            Result resu = new Result();
            if (model.BankName.Length == 0)
            {
                resu.Errors = "“银行名称”不能为空！";
                return resu;
            }
            if (model.BankFullName.Length == 0)
            {
                resu.Errors = "“开户行全称”不能为空！";
                return resu;
            }

            if (model.HolderName.Length == 0)
            {
                resu.Errors = "“账户名”不能为空！";
                return resu;
            }


            if (model.Id == 0)
            {
                Dal.Add(model);
            }
            else
            {
                Dal.Edit(model);
            }
            return resu;
        }

        #endregion

        #region 删除

        /// <summary>
        /// 删除
        /// </summary>
        public void Delete(string IDs, UpdatePanel UpdatePanel1)
        {
            if (string.IsNullOrEmpty(IDs))
            {
                MsgBox.Message("至少选择一项。", UpdatePanel1);
            }
            else
            {
                Dal.Delete(MyConvert.ConvertToArr(IDs));
            }
        }

        #endregion

        #region 加载数据

        /// <summary>
        /// 加载数据
        /// </summary>
        public Bank GetInfo(string ID)
        {
            return Dal.GetInfo(int.Parse(ID));
        }

        #endregion

        #endregion
    }
}